<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://purl.org/kid/ns#" py:extends="'../master.kid'">

<head>
    <meta content="text/html; charset=UTF-8" http-equiv="content-type" py:replace="''"/>
    <title>Online API Doc Dashboard</title>
	<link href="/static/css/template.css" media="screen" rel="Stylesheet" type="text/css" /> 
</head>

<body>
<h2>Templates</h2>

<a href="#" onclick="toggle('new_template'); clr('ta_new_template');fcs('tf_desc'); return false;">new template</a>
<div id="new_template" style="display: none;">
<form id="form_new_template" action="new_template" method="post">
<table>
<tr>
<td width="120"><b>Name</b></td>
<td><input id="tf_desc" type="text" name="name" size="50" /></td>
</tr>
<tr>
<td><b>Edit Template</b></td>
</tr>
<tr>
<td colspan="2">
<textarea id="ta_new_edit_template" rows="4" name="edit_template" cols="72"></textarea>
</td>
</tr>

<tr>
<td><b>View Template</b></td>
</tr>
<tr>
<td colspan="2">
<textarea id="ta_new_view_template" rows="4" name="view_template" cols="72"></textarea>
</td>
</tr>
<tr>
<td colspan="2"><b>Description</b></td>
</tr>
<tr>
<td colspan="2">
<textarea id="ta_new_desc" rows="4" name="description" cols="72"></textarea>
</td>
</tr>
</table>

<a href="#" onclick="submit('form_new_template'); return false;">add</a>
<a href="#" onclick="toggle('new_template'); return false;">cancel</a>
</form>
</div>

<div id="edit_template" py:if="current_template">
<form id="form_edit_template" action="edit_template_commit" method="post">
<table>
<tr>
<td width="120"><b>Name</b></td>
<td><input id="tf_desc" type="text" name="name" size="50" value="$current_template.name" /></td>
</tr>
<tr>
<td><b>Edit Template</b></td>
</tr>
<tr>
<td colspan="2">
<textarea id="ta_new_edit_template" rows="4" name="edit_template" cols="72">${current_template.edit_template}</textarea>
</td>
</tr>

<tr>
<td><b>View Template</b></td>
</tr>
<tr>
<td colspan="2">
<textarea id="ta_new_view_template" rows="4" name="view_template" cols="72">${current_template.view_template}</textarea>
</td>
</tr>
<tr>
<td colspan="2"><b>Description</b></td>
</tr>
<tr>
<td colspan="2">
<textarea id="ta_new_desc" rows="4" name="description" cols="72">${current_template.description}</textarea>
</td>
</tr>
</table>

<input name="template_id" type="hidden" value="$current_template.id"/>
<a href="#" onclick="submit('form_edit_template'); return false;">update</a>
<a href="/template/">cancel</a>
</form>
</div>

<div class="template" onclick="document.location.href='${tg.url('/template/%s' % template.id)}'" py:for="template in templates">
<div class="top">
<h3 py:content="template.name" />
</div>
<div class="bottom">
<span class="contact">
<span class="label">Author</span>
<span py:content="template.author.display_name" />
</span>
<span class="operation">
<span class="label">Operations</span>
<a href="/template/duplicate_template/$template.id">Duplicate</a>
<a href="/template/delete_template/$template.id">Delete</a>
</span>
<div class="desc" py:content="XML(template.description)"/>
</div>
</div>

</body>

</html>
